import {Component, OnInit, AfterContentInit, AfterViewInit} from '@angular/core';
import {Article} from './article';
import {ArticleService} from './article.service';

@Component({
  selector: 'sung-app-articles',
  templateUrl: './articles.component.html',
  styleUrls: ['./articles.component.css'],
  providers: [ArticleService]
})

export class ArticlesComponent implements OnInit, AfterContentInit, AfterViewInit {
  title = '文章列表';
  articles = Article[''];
  constructor(private articleService: ArticleService) { }

  getArticles(): void {
    this.articleService.getArticles().then(articles => this.articles = articles);
  }

  ngOnInit(): void {
    this.getArticles();
  }

  ngAfterContentInit(): void {
    //  alert('文章载入成功！');
  }

  ngAfterViewInit(): void {
    alert('文章载入成功！');
  }

  /*onSelect(article: Article): void {
    this.selectedArticle = article;
  }*/
}
